package com.example.campusmanagement.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.campusmanagement.entity.LostAndFound;
import com.example.campusmanagement.service.LostAndFoundService;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/lost_and_found")
@CrossOrigin(origins = "http://localhost:8081")
public class LostAndFoundController {

    @Autowired
    private LostAndFoundService lostAndFoundService;

    @GetMapping("/username")
    public String list(Integer id) {
        LostAndFound lostAndFound = lostAndFoundService.getById(id);
        return lostAndFound.getName();
    }

    @PostMapping("/add")
    public Boolean addPin(@RequestBody LostAndFound lostAndFound) {
        System.out.println(lostAndFound.getIDs());
        System.out.println(lostAndFound.getName());
        return lostAndFoundService.save(lostAndFound);
    }

    @PostMapping("/list")
    public List<LostAndFound> list() {
        List<LostAndFound> lostAndFounds = lostAndFoundService.list();
        return lostAndFounds;
    }

    @PostMapping("/charging_piles")
    public List<LostAndFound> chargeing_piles() {
        List<LostAndFound> lostAndFounds = lostAndFoundService.list();
        return lostAndFounds;
    }
}
